package book.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;




import book.dao.BaseDao;
import book.dao.ManagerDao;
import book.util.Manager;

public class ManagerDaoImpl implements ManagerDao{
	private Connection connection;
	private PreparedStatement pstmt;
	private ResultSet rs;
	public int findManagerAll(Manager manager) {
		int num=0;
		try {
		connection = BaseDao.getConnection();
		String sql = "select manager_ID,password,name, connection from admin where manager_ID = ? and password = ? and name=?";
		
			pstmt = connection.prepareStatement(sql);
			pstmt.setInt(1, manager.getManager_ID());
			pstmt.setString(2, manager.getPassword());
			pstmt.setString(3, manager.getName());
			rs = pstmt.executeQuery();
			if(rs.next()){
				num = rs.getInt("manager_ID");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			BaseDao.closeAll(rs, pstmt, connection);
		}
		
		return num;
	}

}
